package com.binc.testspring.dao;

import com.binc.testspring.dto.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {

    /**
     *  通过id查询stueden对象
     * @param id 主键
     * @return user对象
     */
    @Select("select * from student where id=#{id}")
    Student queryUserById(Long id);

    @Select("select * from student  ")
    List<Student> allList();


    @Options(useGeneratedKeys = true, keyProperty = "id")
    //options用来定义主键返回,keyProperty指定主键对应的属性
    @Insert("insert into student (id,name,age) values (#{id},#{name},#{age})")
    int insert(Student user);

    // @Select("select * from student  ")
    List<Student> allList2();


}
